<!DOCTYPE html>
<html>

<head>
    <meta name="layout" content="main2"/>
    <g:set var="entityName" value="${message(code: 'messageTemplate.label', default: 'MessageTemplate')}"/>
    <title>新增推送消息模板</title>
    <asset:stylesheet src="homer/vendor/codemirror/codemirror.css"/>
</head>

<body>

<div class="main-body">
    <div class="page-wrapper">
        <!-- Page-header start -->
        <div class="page-header">
            <div class="page-header-title">
                <h4>新增消息模板</h4>
            </div>

            <div class="page-header-breadcrumb">
                <ul class="breadcrumb-title">
                    <li class="breadcrumb-item">
                        <a href="/salesDashboard/index">
                            <i class="icofont icofont-home"></i>
                        </a>
                    </li>
                    <li class="breadcrumb-item">
                        <g:link controller="messageTemplate" action="index">消息模板列表</g:link>
                    </li>
                    <li class="breadcrumb-item"><a href="#!">新增消息模板</a>
                    </li>
                </ul>
            </div>
        </div>
        <!-- Page-header end -->
        <!-- Page-body start -->
        <div class="page-body">
            <g:if test="${flash.message}">
                <div class="message" role="status">${flash.message}</div>
            </g:if>
            <g:hasErrors bean="${this.messageTemplate}">
                <ul class="errors" role="alert">
                    <g:eachError bean="${this.messageTemplate}" var="error">
                        <li <g:if test="${error in org.springframework.validation.FieldError}">data-field-id="${error.field}"</g:if>><g:message
                                error="${error}"/></li>
                    </g:eachError>
                </ul>
            </g:hasErrors>
        <!-- Hover table card start -->
            <div class="card">
                <div class="card-header">
                    <h5>新增消息模板</h5>

                    <div class="card-header-right">

                        <i class="icofont icofont-rounded-down"></i>
                    </div>
                </div>

                <div class="card-block">
                    <g:form action="save" class="form-horizontal">

                        <div class="form-group row">
                            <label class="col-md-2 control-label">名称</label>

                            <div class="col-md-8">
                                <g:textField name="name"  value="${this.messageTemplate?.name}" class="form-control"/>
                            </div>

                        </div>


                        <div class="form-group row">
                            <label class="col-md-2 control-label">内容</label>

                            <div class="col-md-8">
                                <g:textArea name="text" value="${this.messageTemplate?.text}"
                                            class="form-control textarea" rows="4"
                                            cols="40"/>
                            </div>
                        </div>


                        <div class="form-group row">
                            <label class="col-md-2 control-label">模板</label>

                            <div class="col-md-8">

                                <g:textArea name="template" id="code1" value="${this.messageTemplate?.template}"
                                            class="form-control"
                                            rows="15" cols="15"/>

                            </div>
                        </div>

                        <div class="form-group row">
                            <div class="col-md-12">
                                <button class="submitBtn btn btn-info" type="submit">保存</button>
                            </div>
                        </div>
                    </g:form>

                </div>
                <!-- Hover table card end -->
            </div>

            <!-- Page-body end -->
        </div>
    </div>
</div>
<asset:javascript src="homer/vendor/codemirror/codemirror.js"/>
%{-- <asset:javascript src="homer/vendor/codemirror/javascript.js"/> --}%


<script>
    $(document).ready(function () {
        var textarea1 = document.getElementById("code1");
        var editor1 = CodeMirror.fromTextArea(textarea1, {
            lineNumbers: false,
            matchBrackets: true,
            styleActiveLine: true
        });

        $(".submitBtn").click(function () {
            $("#code1").val(editor1.getValue());
        });
    });
</script>
</body>

</html>


